/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Affichage;

import Metier.Dialogue;
import Metier.Lieu;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;

/**
 *
 * @author Loick
 */
public class SupprimerLieu extends JFrame {

    private javax.swing.JButton BTNSupprimerLieu;
    private javax.swing.JList LSTSupprimerLieu;
    private javax.swing.JScrollPane jScrollPane1;
    private List<Lieu> c = new ArrayList<>();
    private Vector<String> v;

    public SupprimerLieu() throws IOException {

        jScrollPane1 = new javax.swing.JScrollPane();
        LSTSupprimerLieu = new javax.swing.JList();
        BTNSupprimerLieu = new javax.swing.JButton();
        v = new Vector<String>();
        Dialogue resurl = new Dialogue();
        c = resurl.getUrlEtLibelleLieu();
        for (Lieu lieu : c) {
            v.add(lieu.getLibelle());
        }
        LSTSupprimerLieu.setListData(v);

        jScrollPane1.setViewportView(LSTSupprimerLieu);

        BTNSupprimerLieu.setText("Supprimer");
        BTNSupprimerLieu.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                for (Lieu lieu : c) {
                    if ((lieu.getLibelle()).equals(LSTSupprimerLieu.getSelectedValue())) {
                            Dialogue supr = new Dialogue();
                            supr.supprimerLieu(lieu);
                            dispose();

                        }
                    
                }
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
                .addComponent(BTNSupprimerLieu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap()));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BTNSupprimerLieu, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(15, Short.MAX_VALUE)));
    }
}
